package com.tmxk.api.days03.cyq;

import java.util.regex.Pattern;

public class RegularExpressionDemo {
    public static void main(String[] args) {
        String num = "123456";
        //使用正则表达式判断当前输入的字符是否都是数字
        boolean pattern = Pattern.matches("\\d +", num);
        System.out.println(pattern);
        //字符串正则匹配
        //定义正则匹配表达式 d{11}
        String regex = "\\d{11}";
        boolean isRegex = num.matches(regex);
        System.out.println("isRegex" +isRegex);
        //手机号 138 188 133  \d等于[0-9] \D 等于[~0-9]
        String regexPhone = "1(38|88|33)\\d{8}";
        String phone  = "188123456789";
        System.out.println(phone.matches(regexPhone));

        String str = "12456@qq.com";
        String str1 = "12345678950";
        System.out.println("charAt(2):" +str.charAt(2));
        //str.charAt(2) 根据字符串指定下标位置返回对应单个字符
        int ch = str1.charAt(2);
        //强调： str.indexOf("5") 获取对应字符串的下标位置，找不到返回负数
        System.out.println(str.indexOf("5")); //3
        //str1.indexOf(ch) ch获取
        System.out.println(str.indexOf(ch));

        //0xFFF == 65535
        System.out.println(0xFFF);
        String certificateNo = "19111019911310555X";
        String certificateNoReg = "([1-9][0-9]{17}|[1-9][0-9]{16}X)";
        System.out.println(certificateNo.matches(certificateNoReg));
    }




}
